package com.erms.lab.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.erms.common.annotation.Log;
import com.erms.common.enums.BusinessType;
import com.erms.lab.domain.SysConferenceHosting;
import com.erms.lab.service.ISysConferenceHostingService;
import com.erms.common.core.controller.BaseController;
import com.erms.common.core.domain.AjaxResult;
import com.erms.common.utils.poi.ExcelUtil;
import com.erms.common.core.page.TableDataInfo;

/**
 * 承办大型会议情况Controller
 * 
 * @author guo
 * @date 2020-03-22
 */
@Controller
@RequestMapping("/lab/hosting")
public class SysConferenceHostingController extends BaseController
{
    private String prefix = "lab/hosting";

    @Autowired
    private ISysConferenceHostingService sysConferenceHostingService;

    @RequiresPermissions("lab:hosting:view")
    @GetMapping()
    public String hosting()
    {
        return prefix + "/hosting";
    }

    /**
     * 查询承办大型会议情况列表
     */
    @RequiresPermissions("lab:hosting:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SysConferenceHosting sysConferenceHosting)
    {
        startPage();
        List<SysConferenceHosting> list = sysConferenceHostingService.selectSysConferenceHostingList(sysConferenceHosting);
        return getDataTable(list);
    }

    /**
     * 导出承办大型会议情况列表
     */
    @RequiresPermissions("lab:hosting:export")
    @Log(title = "承办大型会议情况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SysConferenceHosting sysConferenceHosting)
    {
        List<SysConferenceHosting> list = sysConferenceHostingService.selectSysConferenceHostingList(sysConferenceHosting);
        ExcelUtil<SysConferenceHosting> util = new ExcelUtil<SysConferenceHosting>(SysConferenceHosting.class);
        return util.exportExcel(list, "hosting");
    }

    /**
     * 新增承办大型会议情况
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存承办大型会议情况
     */
    @RequiresPermissions("lab:hosting:add")
    @Log(title = "承办大型会议情况", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SysConferenceHosting sysConferenceHosting)
    {
        return toAjax(sysConferenceHostingService.insertSysConferenceHosting(sysConferenceHosting));
    }

    /**
     * 修改承办大型会议情况
     */
    @GetMapping("/edit/{hostId}")
    public String edit(@PathVariable("hostId") Long hostId, ModelMap mmap)
    {
        SysConferenceHosting sysConferenceHosting = sysConferenceHostingService.selectSysConferenceHostingById(hostId);
        mmap.put("sysConferenceHosting", sysConferenceHosting);
        return prefix + "/edit";
    }

    /**
     * 修改保存承办大型会议情况
     */
    @RequiresPermissions("lab:hosting:edit")
    @Log(title = "承办大型会议情况", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SysConferenceHosting sysConferenceHosting)
    {
        return toAjax(sysConferenceHostingService.updateSysConferenceHosting(sysConferenceHosting));
    }

    /**
     * 删除承办大型会议情况
     */
    @RequiresPermissions("lab:hosting:remove")
    @Log(title = "承办大型会议情况", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sysConferenceHostingService.deleteSysConferenceHostingByIds(ids));
    }
}
